module.exports = {
  generateMessage: function(context, events, done) {
    const userId = Math.floor(Math.random() * 10000);
    const message = {
      userId: `user${userId}`,
      username: `User${userId}`,
      content: `测试弹幕消息${Math.floor(Math.random() * 1000)}`,
      color: "#FF0000",
      fontSize: 16,
      position: "normal"
    };
    
    context.vars.message = JSON.stringify(message);
    return done();
  },
  
  connectToBarrage: function(context, events, done) {
    // 连接到弹幕WebSocket端点
    context.wsConnect("/barrage");
    return done();
  },
  
  disconnect: function(context, events, done) {
    // 断开连接
    if (context.ws) {
      context.ws.close();
    }
    return done();
  }
};